//
//  BaseViewController.m
//  Rongniu
//
//  Created by Apple on 16/2/22.
//  Copyright © 2016年 Fangwei. All rights reserved.
//

#import "BaseViewController.h"
#import "Common.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)initNavigationBar
{
    //  Subclass TODO
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initNavigationBar];

    if (_enableReturnButton) {
        
        self.view.backgroundColor = [UIColor whiteColor];

    UIButton *retButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [retButton setImage:FW_IMAGE(@"nav_reutrn") forState:UIControlStateNormal];
    retButton.frame = CGRectMake(-5, 0, 24, 24);
    if (!FW_IOS7) {
        retButton.frame = CGRectMake(0, 0, kBorder_NavButton, kBorder_NavButton);
    }
    //    setButton.backgroundColor = [UIColor redColor];
    [retButton addTarget:self action:@selector(retButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *retItem = [[UIBarButtonItem alloc] initWithCustomView:retButton];
    self.navigationItem.leftBarButtonItem = retItem;
}
}
- (void)retButtonAction:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
////显示网络加载的方法
//- (void)showLoadingView:(NSString *)title {
//    
////    if (_hud == nil) {
//    
//        UIWindow *window = [UIApplication sharedApplication].keyWindow;
//        _hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
//        //设置视图的样式
//        //        _hud.mode = MBProgressHUDModeCustomView;
//        
//        //设置动画样式
//        /*
//         MBProgressHUDAnimationFade,
//         MBProgressHUDAnimationZoom
//         */
//        //        _hud.animationType = MBProgressHUDAnimationZoom;
////    }
//    
//    //设置标题
//    _hud.labelText = title;
//    
//    //设置覆盖视图
//    _hud.dimBackground = YES;
//}
//
////隐藏网络加载的方法
//- (void)hiddenView {
//    [_hud hide:YES];
//}

#pragma mark - 设置UITableView分割线顶格
-(void)setCellSeperatorToLeft:(UITableViewCell *)cell{
    setLastCellSeperatorToLeft(cell);
}

static void setLastCellSeperatorToLeft(UITableViewCell* cell)
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){
        
        [cell setPreservesSuperviewLayoutMargins:NO];
    }
}
#pragma mark -16进制计算颜色
/*!
 * @method 通过16进制计算颜色
 * @abstract
 * @discussion
 * @param 16机制
 * @result 颜色对象
 */
- (UIColor *)colorFromHexRGB:(NSString *)inColorString{
    UIColor *result = nil;
    unsigned int colorCode = 0;
    unsigned char redByte, greenByte, blueByte;
    
    if (nil != inColorString)
    {
        NSScanner *scanner = [NSScanner scannerWithString:inColorString];
        (void) [scanner scanHexInt:&colorCode]; // ignore error
    }
    redByte = (unsigned char) (colorCode >> 16);
    greenByte = (unsigned char) (colorCode >> 8);
    blueByte = (unsigned char) (colorCode); // masks off high bits
    result = [UIColor
              colorWithRed: (float)redByte / 0xff
              green: (float)greenByte/ 0xff
              blue: (float)blueByte / 0xff
              alpha:1.0];
    return result;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
